from django import forms
from django.core.exceptions import ValidationError


def cellphone_validator(value):
    if not value.isdigit():
        raise ValidationError('must be digit')
    if len(value) != 11:
        raise ValidationError('length must be 11')


class SignupForm(forms.Form):
    name = forms.CharField(max_length=20)
    password = forms.CharField(max_length=40, widget=forms.PasswordInput())
    cellphone = forms.CharField(max_length=11, validators=[cellphone_validator])
